VERSION 5.00
Begin VB.Form fMain 
   AutoRedraw      =   -1  'True
   Caption         =   "Main-Form: Click Me"
   ClientHeight    =   2580
   ClientLeft      =   120
   ClientTop       =   465
   ClientWidth     =   5790
   LinkTopic       =   "Form1"
   ScaleHeight     =   2580
   ScaleWidth      =   5790
   StartUpPosition =   2  'Bildschirmmitte
   Begin VB.Timer Timer1 
      Interval        =   500
      Left            =   180
      Top             =   180
   End
End
Attribute VB_Name = "fMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Declare Function LoadLibraryW Lib "kernel32" (ByVal pFileName As Long) As Long 'used to preload DirectCOM.dll on App-Startup

Private i As Long, TWs(1 To 4) As cThreadWrapper '<- define space for 4 ThreadWrapper-instances

Private Sub Form_Load()
  LoadLibraryW StrPtr(App.Path & "\Bin\DirectCom.dll") 'preload DirectCOM-dll from a SubFolder of the App.Path
  Caption = "MainThread-ID: " & App.ThreadID 'reflect the ID of our Main-Thread in the MainForms-Caption
End Sub

Private Sub Form_Click()
  For i = 1 To 4
    Set TWs(i) = New cThreadWrapper 'create the Thread-Wrapper-Instances which all run here on the Main-Thread
        TWs(i).StartThread 'but are each responsible for a "Remote-Thread" which gets started here
  Next i
End Sub

Private Sub Timer1_Timer() 'just an Update-Timer, which renders Information from the running Threads here on the Main-Thread
  Cls
  For i = 1 To 4
    If ObjPtr(TWs(i)) Then Print "Thread " & i & " (ThreadID: " & TWs(i).ThreadID & ", FPS: " & TWs(i).FPS & ")"
  Next i
End Sub
